var app = getApp()
var Utils = require('../../../../utils/util.js');
Page({
  /**
   * 页面的初始数据
   */
  data: {
    textareatxt:"",
    popif: false,
    inquiry:"",
    argeen:true,
    steps: ["上传处方", "完善信息", "选择药品", "医生开药"],
    upload_picture_list: [],
    stepnum:0,
    speedlist:[
      { tit: "祛斑/去痘印", text: "的哈哈大华大厦宏大的" },
      { tit: "痔疮/痘痘", text: "的哈哈大华大厦宏大的" },
      { tit: "去黑头", text: "的哈哈大华大厦宏大的" },
      { tit: "脚气", text: "的哈哈大华大厦宏大的" },
      { tit: "阳痿", text: "的哈哈大华大厦宏大的" },
      { tit: "早泄", text: "的哈哈大华大厦宏大的" },
      { tit: "湿疹", text: "的哈哈大华大厦宏大的" },
      { tit: "避孕", text: "的哈哈大华大厦宏大的" },
      {tit:"阴道炎",text:"的哈哈大华大厦宏大的"},
    ]
  },
  //调单提交
  infomationbtn(e){
    let vals = e.detail.value;
    console.log(e)
    if (vals.zhengzhuang == "" || vals.zhengzhuang.length < 10){
      wx.showToast({
        title: '提问至少10字',
        icon: 'none'
      })
    }else{
      let imgs = this.data.upload_picture_list
      //提交
      wx.navigateTo({
        url: '/hyb_yl/zhuanjiasubpages/pages/huanzhexinxi/huanzhexinxi?inquiry=' + this.data.inquiry,
      })
    }
  },
  // 常见疾病
  chooseLabel(e){
    let i = e.currentTarget.dataset.dex, arrs = this.data.speedlist
    this.setData({
      textareatxt: arrs[i].text
    })
  },
  //关闭模态框
  closepop(){
    this.setData({
      popif:false
    })
  },
  nopingzheng(){
    this.setData({
      popif: true
    })
  },
  //开方
  navUrgent(){
    wx.navigateTo({
      url: '/hyb_yl/czhuanjiasubpages/pages/chufangmes/chufangmes?inquiry=3',
    })
  },
  //删除图片
  deleteimg: function (e) {
    var that = this;
    var i = e.currentTarget.dataset.index;
    var imgArr = that.data.data_arr;
    imgArr.splice(i, 1);
    that.setData({
      upload_picture_list: imgArr
    })
  },
  // 上传图片
  uploadimg: function () {
    let that = this;
    var uniacid = app.siteInfo.uniacid
    var data_arr = that.data.upload_picture_list;
    wx.chooseImage({
      count: 5,
      sizeType: ['original', 'compressed'],
      sourceType: ['album', 'camera'],
      success(res) {
        console.log(res)
        // tempFilePath可以作为img标签的src属性显示图片
        const tempFilePaths = res.tempFilePaths
        for (var i = 0; i < tempFilePaths.length; i++) {
          wx.uploadFile({
            url: that.data.url + 'app/index.php?i=' + uniacid + '&c=entry&a=wxapp&do=Uploadback&m=hyb_yl',
            filePath: tempFilePaths[i],
            name: 'upfile',
            formData: [],
            success: function (res) {
              console.log(res)
              data_arr.push(res.data)
              that.setData({
                upload_picture_list: data_arr
              })
            }
          })
        }
      }
    })
  },
  // 是否同意协议
  radioChange() {
    this.setData({
      argeen: !this.data.argeen
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var bgc = wx.getStorageSync('color')
    wx.setNavigationBarColor({
      frontColor: "#ffffff",
      backgroundColor: bgc,
    })
    let that = this
    app.util.request({
      'url': 'entry/wxapp/Hzbingli.url',
      success: function (res) {
        that.setData({
          url: res.data,
        })
      }
    })
    this.setData({
      inquiry: options.inquiry
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})